package com.bart.scala.ch16.scalajhttp

/**
 * https://github.com/scalaj/scalaj-http
 * https://www.cnblogs.com/barrywxx/p/10850312.html
 */
object ScalajHttpTests {

  def main(args: Array[String]): Unit = {
    import scalaj.http._
    // 1） get 方式
    val response: HttpResponse[String] = Http("http://foo.com/search").param("q","monkeys").asString
    response.body
    response.code
    response.headers
    response.cookies

    // 1） get 方式
    val request: HttpRequest = Http("http://date.jsontest.com/")
    val responseOne = request.asString
    val responseTwo = request.asString

    // 2）post 方式
    Http("http://foo.com/add").postForm(Seq("name" -> "jon", "age" -> "29")).asString

  }

}
